package com.matt.domain.course;

import com.matt.commons.model.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/9/25
 * *******************************
 */
@Entity
@Table(name = "children_course_change_record")
@Data
@EqualsAndHashCode(callSuper = true)
public class ChildrenCourseChangeRecord extends Model{

    @Column(columnDefinition = " varchar(32)  COMMENT '宝宝id' ")
    private String childrenId;

    @Column(columnDefinition = " int DEFAULT 0 COMMENT '增量' ")
    private Integer delta = 0;

    @Column(columnDefinition = " int DEFAULT 0 COMMENT '现在剩余课时' ")
    private Integer nowCourseSize = 0;

    @Column(columnDefinition = " varchar(32)  COMMENT ' 操作人员id' ")
    private String operatorId;

    @Column(columnDefinition = " varchar(50)  COMMENT ' 操作人员姓名' ")
    private String operatorName;

    @Column(columnDefinition = " varchar(100)  COMMENT ' 备注信息' ")
    private String remark;

    @Column(columnDefinition = " datetime  COMMENT ' 课程时间 ' ")
    private Date created = new Date();

    public static ChildrenCourseChangeRecord of(String operatorId, String childrenId, String remark, Integer times, Integer leftTimes, String operatorName){
        ChildrenCourseChangeRecord changeRecord = new ChildrenCourseChangeRecord();
        changeRecord.setChildrenId(childrenId);
        changeRecord.setOperatorId(operatorId);
        changeRecord.setOperatorName(operatorName);
        changeRecord.setDelta(times);
        changeRecord.setRemark(remark);
        changeRecord.setNowCourseSize(leftTimes);
        return changeRecord;
    }
}
